package function;

import model.Author;
import model.GetAuthors;

import java.util.List;

public class Limit {
    public static void main(String[] args) {
        List<Author> authors = GetAuthors.getAuthors();
        authors.stream()
                .distinct()
                .sorted((o1,o2)->o2.getAge()-o1.getAge())
                .limit(2)
                .forEach((author -> {
                    System.out.println(author.getName()+" "+author.getAge());
                }));

    }
}
